package cn.fczds.camhelper.order.controller;

import cn.fczds.camhelper.base.response.JsonResult;
import cn.fczds.camhelper.order.Service.OrderService;
import cn.fczds.camhelper.order.pojo.dto.OrderQuery;
import cn.fczds.camhelper.order.pojo.dto.OrderSaveParam;
import cn.fczds.camhelper.order.pojo.dto.OrderStatus;
import cn.fczds.camhelper.order.pojo.vo.OrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/order/")
public class OrderController {
    @Autowired
    OrderService orderService;

    @GetMapping("select")
    public JsonResult select(OrderQuery orderQuery) {
        log.debug("查询订单:OrderQuery={}", orderQuery);
        List<OrderVO> list = orderService.select(orderQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("insert")
    public JsonResult insert(OrderSaveParam orderSaveParam) {
        log.debug("新增订单数据为orderSaveParam={}", orderSaveParam);
        orderService.insert(orderSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("selectAll")
    public JsonResult selectAll(OrderQuery orderQuery) {
        log.debug("查询所有订单为orderQuery={}", orderQuery);
        List<OrderVO> list = orderService.selectAll(orderQuery);
        return JsonResult.ok(list);
    }

    @GetMapping("selectStatus")
    public JsonResult selectStatus(OrderStatus orderStatus) {
        log.debug("orderStatus={}", orderStatus);
        List<OrderVO> list = orderService.selectStatus(orderStatus);
        return JsonResult.ok(list);
    }

}
